Repository navigation
fix(validate): reject non-integer values in integer-typed fields - #136
Merged
Merged
Conversation
A CPU record with tdp_w 11.5 passed validation and only failed in the dump, where the read schema types the field as an integer. The validator now lists the integer fields of each category and reports a fractional number, a boolean or a string in any of them, and does the same for the members of list-of-integer fields. The lists are written out next to the required-field sets so the module still imports with the standard library alone; TechAPI's PR checks run it without installing the engine. A unit test derives the same lists from the models and fails when the two disagree, and another imports the validator with site-packages off the path. Whole floats such as 65.0 stay valid: the read schemas load them as integers and 15 CPU records hold one. The device catalog's own integer check is replaced by the shared one.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
Part of #98. A CPU record with
tdp_w: 11.5passed validation and only failed later, when the dump built the read schema, because the API types the field as an integer. The validator now rejects fractional numbers, booleans and strings in every field the models type as an integer, so the dataset's PR checks catch it before a dump does.Changes
app/validate.py: explicit sets of integer fields per category, next to the required-field sets, and one shared check. Whole floats such as65.0stay valid: the serialiser accepts them and 15 existing CPU records hold one. The device catalog's own integer check is replaced by the shared one.app.categoriesandapp.data_root. TechAPI's PR checks run it from the submodule without installing the engine, so this matters. A unit test imports it in a subprocess with-I -S.Checks
ruff,mypy app,pytest tests/unit(698 passed) locally.